#include <stdio.h>
int sum[5000] = {0};
int main()
{
	int n = 0, m = 0;
	scanf("%d %d", &n, &m);
	int s = 0, d = 0;
	for (int i = 0; i < n; i++ ) {
		scanf("%d", &d);
		s += d;
		sum[i] = s;
	}
	
	int front = 0, end = 0, frontSum = 0;	
	for ( int i = 0; i < m; i++ ) {
		scanf("%d %d", &front, &end);
		front = front - 1;
		if ( front < 0 ) {
			frontSum = 0;
		}
		else {
			frontSum = sum[front];
		}
		if ( end > n - 1 ) {
			end = n - 1;
		}
		printf("%d\n", sum[end] - frontSum);
	}
	return 0;
}
